/** * ACD_1.mq4 * A and C values **/ #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 White //open range #property indicator_color2 White #property indicator_color3 Yellow //a values #property indicator_color4 Yellow #property indicator_color5 Aqua //c values #property indicator_color6 Aqua //Input Params extern string OpenRangeStart = "08:30"; extern string OpenRangeEnd = "09:00"; extern bool Use_Default_A_and_C_Values = true; extern double A_Value_Pips = 0; extern double C_Value_Pips = 0; extern bool UseAlerts = false; extern bool DisplayOpeningRange = true; extern bool DisplayAs = true; extern bool DisplayCs = true; double Buffer1[]; double Buffer2[]; double Buffer3[]; double Buffer4[]; double Buffer5[]; double Buffer6[]; double EUR_USD_A_VALUE = 0.0012; double EUR_USD_C_VALUE = 0.0018; double GBP_USD_A_VALUE = 0.0016; double GBP_USD_C_VALUE = 0.0023; double USD_CHF_A_VALUE = 0.0014; double USD_CHF_C_VALUE = 0.0021; double USD_JPY_A_VALUE = 0.10; double USD_JPY_C_VALUE = 0.15; double USD_CAD_A_VALUE = 0.0012; double USD_CAD_C_VALUE = 0.0018; double AUD_USD_A_VALUE = 0.0008; double AUD_USD_C_VALUE = 0.0013; double aValue; double cValue; double aUp=0; double aDown=0; double cUp=0; double cDown=0; double openRangeHigh; double openRangeLow; bool aUpBefore=false; bool aDownBefore=false; bool cUpBefore=false; bool cDownBefore=false; int init() { SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0, 158); SetIndexBuffer(0,Buffer1); SetIndexLabel(0,"O/R High"); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1, 158); SetIndexBuffer(1,Buffer2); SetIndexLabel(1,"O/R Low"); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2, 250); SetIndexBuffer(2,Buffer3); SetIndexLabel(2,"A Up"); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3, 250); SetIndexBuffer(3,Buffer4); SetIndexLabel(3,"A Down"); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4, 167); SetIndexBuffer(4,Buffer5); SetIndexLabel(4,"C Up"); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5, 167); SetIndexBuffer(5,Buffer6); SetIndexLabel(5,"C Down"); return(0); } int deinit() { return(0); } int start() { selectValues(); if (UseAlerts) displayAlert(); string barTime=""; int openBar, closeBar; bool openRangeStarted = false; bool openRangeCompleted = false; for(int i=Bars; i>=0; i--) { barTime = TimeToStr(Time[i], TIME_MINUTES); if (!openRangeStarted && barTime>=OpenRangeStart && barTime= OpenRangeEnd) { closeBar = i + 1; openRangeCompleted = true; } if (openRangeStarted && openRangeCompleted) { calculateOpenRangeValues(openBar, closeBar); openRangeStarted = false; openRangeCompleted = false; } if (openBar>0) { drawIndicators(i); } } return(0); } void calculateOpenRangeValues(int openBar, int closeBar) { openRangeHigh = High[Highest(NULL, 0, MODE_HIGH, (openBar - closeBar + 1), closeBar)]; openRangeLow = Low[Lowest(NULL, 0, MODE_LOW, (openBar - closeBar + 1), closeBar)]; } void selectValues() { if (Use_Default_A_and_C_Values) { if (Symbol()=="EURUSD") { aValue = EUR_USD_A_VALUE; cValue = EUR_USD_C_VALUE; } else if (Symbol()=="GBPUSD") { aValue = GBP_USD_A_VALUE; cValue = GBP_USD_C_VALUE; } else if (Symbol()=="USDCHF") { aValue = USD_CHF_A_VALUE; cValue = USD_CHF_C_VALUE; } else if (Symbol()=="USDJPY") { aValue = USD_JPY_A_VALUE; cValue = USD_JPY_C_VALUE; } else if (Symbol()=="USDCAD") { aValue = USD_CAD_A_VALUE; cValue = USD_CAD_C_VALUE; } else if (Symbol()=="AUDUSD") { aValue = AUD_USD_A_VALUE; cValue = AUD_USD_C_VALUE; } } else { aValue = A_Value_Pips * Point; cValue = C_Value_Pips * Point; } } void drawIndicators(int curBar) { if (openRangeHigh<=0 || openRangeLow <=0) { aUp=0; cUp=0; aDown=0; cDown=0; return(0); } aUp = openRangeHigh + aValue; cUp = openRangeHigh + cValue; aDown = openRangeLow - aValue; cDown = openRangeLow - cValue; if (DisplayOpeningRange) { Buffer1[curBar]=openRangeHigh; Buffer2[curBar]=openRangeLow; } if (DisplayAs) { Buffer3[curBar]=aUp; Buffer4[curBar]=aDown; } if (DisplayCs) { Buffer5[curBar]=cUp; Buffer6[curBar]=cDown; } } void displayAlert() { if (cDownBefore || cUpBefore) { return; } if (aUpBefore || aDownBefore) { if (aUpBefore && cDown!=0 && BidcUp) { cUpBefore=true; Alert(Symbol()," ","C Up"," ", Bid); } } else if (aUp!=0 && Bid>aUp) { aUpBefore=true; Alert(Symbol()," ","A Up"," ", Bid); } else if (aDown!=0 && Bid